#pragma once

#include "Scanner.h"
#include "CharacterTableChecker.h"

#include "CodeGenerator.h"

class CCodeGeneratorManager
{
public:
	CCodeGeneratorManager(CScanner & scanner, CCodeGenerator & codeGenerator);
	~CCodeGeneratorManager();
	void SetChecker(CCharacterTableChecker * checker);
	void SetCurrRowName(std::string const & currRowName);

	void R9();
	void R26();
	void R28();
	void R33();
	void R34();
	void R35();
	void R36();
	void R37();
	void R38();
	void R39();
	void R40();
	void R42();
	void R43();
	void R44();
	void R45();
	void R47();
	void R50();
	void R57();
	void R58();
	void R59();
	void R60();
private:
	void ConstructorBegin();
	void ConstructorEnd();

	void FunctionBegin();
	void FunctionEnd();

	void CopyVariables(std::string const & className, std::string const & objName, bool back = false);

	std::string CheckVar(std::string & v);
	std::string IntToString(int i);

	CScanner & m_scanner;
	CCharacterTableChecker * m_checker;

	CCodeGenerator & m_codeGenerator;

	bool m_isSubProgram;

	std::vector<std::string> m_params;
	std::vector<std::string> m_localVars;
	std::stack<std::string> m_operations;
	std::map<std::string, std::string> m_arrs;
	std::map<std::string, std::string> m_objects;
};

